<?php
/**
 * Zend Framework (http://framework.zend.com/)
 *
 * @link      http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository
 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
 * @license   http://framework.zend.com/license/new-bsd New BSD License
 */

namespace Application\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

class FooterController extends AbstractActionController
{
	protected $PaysTable;
	protected $RegionsTable;
	protected $ActivitesSejourTable;
	protected $AgenceTable;
	protected $PaysRegionsTable;
	
    public function ChargerListesDonneesAction()
	{
		if($_SERVER['REQUEST_METHOD'] == "GET"){

			$paysregions = $this->getPaysRegionsTable()->fetchAllUsed();
			$activites = $this->getActivitesSejourTable()->fetchAllUsed();
			$agences = $this->getAgenceTable()->fetchAllUsed();
			
			echo json_encode(array("paysregions" => $paysregions, "activites" => $activites, "agences" => $agences ));
		}
	
		return $this->response;
	}

	public function MentionslegalesAction()
	{
		$this->layout('layout/layoutpageinfo');
	}

	public function PageinfoAction()
	{
		$this->layout('layout/layoutpageinfo');
	}

	public function QuisommesnousAction()
	{
		return $this->forward()->dispatch('Application\Controller\Footer', array(
    	  'action'	=> 'Pageinfo',
	      // 'sejours' => $sejoursFiltres,
	      // 'titreFiltre' => "Séjours proposés par l'agence ".$agences->libelle
	    ));
	}

	public function NouscontacterAction()
	{
		return $this->forward()->dispatch('Application\Controller\Footer', array(
    	  'action'	=> 'Pageinfo',
	      // 'sejours' => $sejoursFiltres,
	      // 'titreFiltre' => "Séjours proposés par l'agence ".$agences->libelle
	    ));
	}

	/*************************************************************************************************************/


	public function getPaysTable()
	{
		if( !$this->PaysTable ){
			$sm = $this->getServiceLocator();
			$this->PaysTable = $sm->get("Application\Model\PaysTable");
		}
		return $this->PaysTable;
	}
	
	public function getRegionsTable()
	{
		if( !$this->RegionsTable ){
			$sm = $this->getServiceLocator();
			$this->RegionsTable = $sm->get("Application\Model\RegionsTable");
		}
		return $this->RegionsTable;
	}

	public function getActivitesSejourTable()
	{
		if( !$this->ActivitesSejourTable ){
			$sm = $this->getServiceLocator();
			$this->ActivitesSejourTable = $sm->get("Application\Model\ActivitesSejourTable");
		}
		return $this->ActivitesSejourTable;
	}

	public function getAgenceTable()
	{
		if( !$this->AgenceTable ){
			$sm = $this->getServiceLocator();
			$this->AgenceTable = $sm->get("Application\Model\AgenceTable");
		}
		return $this->AgenceTable;
	}

	public function getPaysRegionsTable()
	{
		if( !$this->PaysRegionsTable ){
			$sm = $this->getServiceLocator();
			$this->PaysRegionsTable = $sm->get("Application\Model\PaysRegionsTable");
		}
		return $this->PaysRegionsTable;
	}
}
